import Vue from 'vue'
import Vuex from 'vuex'
import api from '@/api/api.js'
Vue.use(Vuex)
export default  new Vuex.Store({
    state: {
      count: 0,
      cityList:[],
      chooseShopList:[],
      adminDetail:{},
      warehouseDetail:{
      },
      warehouseReple:{ //补货显示仓库
      },
      warehouseRepleGoods:[],
      warehouseList:[], 
      purchaseOrderDetail:{ //采购订单
      },
      checkOrders:[], //开票选择
      checkGoods:[],
      messageDetail:{},
      messageNum: '',
      showIndex: false,
      myStoreId:'',
    },
    mutations: {
      increment (state) {
        state.count++
      },
      setShopList(state,list){
        state.chooseShopList=list
      },
      setAdminDetail(state,obj){
        state.adminDetail = obj
      },
      setWarehouseDetail(state,obj){
        state.warehouseDetail = obj
      },
      setWarehouseList(state,list){
        state.warehouseList = list
      },
      setPurchaseOrderDetail(state,obj){
        state.purchaseOrderDetail = obj
      },
      setCheckGoods(state,obj){
        state.checkGoods = obj
      },
      setCheckOrders(state,arr){
        state.checkOrders = arr
      },
      setWarehouseReple(state,obj){
        state.warehouseReple = obj
      },
      setWarehouseRepleGoods(state,arr){
        state.warehouseRepleGoods = arr
      },
      setMessageDetail(state,obj){
        state.messageDetail = obj
      },
      setMessageNum(state,num){
        state.messageNum = num
      },
      setShowIndex(state,bool){
        state.showIndex = bool
      },
      setMyStoreId(state,str){
        state.myStoreId = str
      },
      
    },
    actions:{
      // getCity (){

      // }
      getMessageNum(context){
        // increment (context) {
        //   context.commit('increment')
        // }
        api.messageMng.getUnReadCount({},res=>{
          context.commit('setMessageNum',res.result);
        })
      }
    }
  }) 